<template>
  <view>
 
     <view>
		 <uni-card>
        <uni-easyinput type="password" :passwordIcon="false" v-model="password" placeholder="请输入新密码" ></uni-easyinput>
      
     
        <uni-easyinput type="password" v-model="confirmPassword" placeholder="请再次输入密码" style="margin-top: 15rpx;" ></uni-easyinput>
      
       <button type="primary" @click="submit" style="margin-top: 15rpx;">提交</button>
        </uni-card>
   </view>
  </view>
</template>

<script>
  import { updateUserPwd } from "@/api/system/user"
  
  export default {
    data() {
      return {
       password:null,
	   confirmPassword:null,
		UserForm:{
			password:null,
			userName:null,
			realName:null,
			rowId:null,
			userType:null,
			userPhone:null,
			userAvator:null,
			userStatus:null,
			
		},
        }
     
    },
    onLoad() {
      this.getUser()
    },
    methods: {
		getUser() {
		 this.$store.dispatch('GetInfo').then(res => {
		  this.user=res.user
		 })
		},
      submit() {
		  if(this.password !=this.confirmPassword){
		  	  this.$modal.msgSuccess("密码不一致")
			  return
		  }
		  this.UserForm.password=this.password
		  this.UserForm.userName=this.user.userName
		  this.UserForm.realName=this.user.realName
		  this.UserForm.rowId=this.user.rowId
		  this.UserForm.userType=this.user.userType
		  this.UserForm.userPhone=this.user.userPhone
		  this.UserForm.userAvator=this.user.userAvator
		  this.UserForm.userStatus=this.user.userStatus
		  updateUserPwd(this.UserForm).then(response => {
            this.$modal.msgSuccess("修改成功")
			 this.$tab.reLaunch('/pages/login')
        
        })
      }
    }
  }
</script>

<style lang="scss">
  page {
    background-color: #ffffff;
  }

  .pwd-retrieve-container {
    padding-top: 36rpx;
    padding: 15px;
  }
</style>
